#===============================================================================
#  File:    0A7-AppendixD-Influence.R
#  Date:    June, 2022 
#  Author:  Natalia Umansky
#  Purpose: Replicating figures displayed in the Appendix D
#===============================================================================

# LIBRARIES
#===============================================================================

require(quanteda)
require(LSX)
library(data.table)
library(rtweet)
library(stringr)
library(stringi)
library(qdapRegex)
library(tidyverse)
library(kableExtra)
library(ggplot2)
library(cowplot)

quanteda_options(threads = 8)

# IMPORT DATA
#===============================================================================

dfmain <- fread("~/security-tweets-amazon.csv")

# Retweet distribution
#===============================================================================

pdf("~/Figure-A9.pdf")
ggplot(subset(dfmain, !is.na(group)), aes(x = retweet_count, y = as.factor(0))) +
  geom_boxplot(width = 0.4 ) +
  facet_wrap(. ~ group, ncol = 2) +
  coord_flip() +
  ggtitle("") +
  xlab("Number of retweets") + ylab("") +
  theme_bw() +
  theme(plot.title = element_text(size = 25),
        plot.title.position = "plot",
        text = element_text(size = 25),
        axis.text = element_text(size = 9),
        axis.title = element_text(size = 20),
        axis.ticks.x = element_blank(),
        axis.text.x = element_blank(),
        legend.position = "right",
        legend.title = element_text(size = 15),
        legend.text = element_text(size = 15),
        legend.key.size = unit(0.4, "cm"),
        strip.background =element_rect(fill="white"),
        strip.text.x = element_text(size = 15))
dev.off()




